#include "matrixMath.h"

xMatrix::xMatrix(int n,int m)
{
  this->n = n;
  this->m = m;
  this->matrix = new double*[n];
  for (int i = 0; i < n; i++)
    this->matrix[i] = new double[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      this->matrix[i][j] = 0;
}
xMatrix::~xMatrix()
{
  for (int i = 0; i < this->n; ++i)
    delete (this->matrix[i]);
  delete (this->matrix);
}
void xMatrix::printMatrix()
{
  for (int i = 0; i < this->n; i++)
  {
    for (int j = 0; j < this->m; j++)
      std::cout << this->matrix[i][j] << "   " << std::endl;
    std::cout << std::endl;
  }
}
void xMatrix::setMatrix(double **arr,int n,int m)
{
  if (this->n != n)
    std::cout << "Can not set matrix with size " << n << "to matrix with size " << this->n << std::endl;
  if (this->m != m)
    std::cout << "Can not set matrix with size " << m << "to matrix with size " << this->m << std::endl;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      this->matrix[i][j] = arr[i][j];
}
void xMatrix::zero()
{
  for (int i = 0; i < this->n; i++)
    for (int j = 0; j < this->m; j++)
      this->matrix[i][j] = 0;
}
void xMatrix::eye()
{
  for (int i = 0; i < this->n; i++)
      this->matrix[i][i] = 1;
}